package com.course.business.controller;

import com.course.server.dto.R;
import com.course.server.exception.ValidatorException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Classname ControllerExceptionHandler
 * @Description TODO
 * @Date 2023-11-27 0:02
 * @Created by 贾悦栋
 */
@ControllerAdvice
@Slf4j
public class ControllerExceptionHandler {

    @ExceptionHandler(value = ValidatorException.class)
    @ResponseBody
    public R validatorExceptionHandler(ValidatorException e){
        log.warn(e.getMessage());
        // return R.error(e.getMessage());
        return R.error("请求参数异常");
    }
}
